package com.learn.rabbitmq.factory;

import javax.annotation.Resource;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DefaultEventSend implements SendFactory {

	@Resource(name = "fanoutTemplate")
	private AmqpTemplate fanoutTemplate;
	
	@Autowired
	private AmqpTemplate amqpTemplate;
	
	@Override
	public void send(Event event) {
		fanoutTemplate.convertAndSend(event);
	}

	@Override
	public void sendByRoutingKey(Event event) {
		amqpTemplate.convertAndSend(event.type.name(), event);
		
	}
	
	

}
